<?php
if(!isset($_REQUEST['search'])) {
	echo '<h2>Enter a keyword or two to search...</h2>';
	exit(0);
}
if (isset($_REQUEST['p'])) {
	$p = $_REQUEST['p'];
} else {
	$p=0;
}
$search=$_REQUEST['search'];
$trimmed=trim($search);
$limit = 15;
$start = $p * $limit;
$sql = "SELECT * FROM links WHERE description LIKE \"%$trimmed%\" LIMIT $start,$limit";
if(!$result=mysql_query($sql)) {
	echo 'Could not execute search operation.';
	exit(0);
}
$found=mysql_num_rows($result);
?>
<div class="alert alert-info"><?=$found;?> links matched search criteria.</div>

<?php
	generate_table($result);
	generate_pagi($found, $limit, $p);
	$pagi=$found/$limit;
?>